﻿using Terraria;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;

namespace HardcoreGame.Common.GlobalTiles
{
    public class SnowBiomeMiningRestriction : GlobalTile
    {
        public override bool CanExplode(int i, int j, int type)
        {
            if (IsInSnowBiome(i, j) && IsOreTile(type) && !PlayerHasLavaPickaxe(Main.LocalPlayer))
            {
                return false;
            }
            return base.CanExplode(i, j, type);
        }
        public override bool CanKillTile(int i, int j, int type, ref bool blockDamaged)
        {
            if (IsInSnowBiome(i, j) && IsOreTile(type) && !PlayerHasLavaPickaxe(Main.LocalPlayer))
            {
                Main.NewText(Language.GetTextValue("Mods.HardcoreGame.Tips.6"), 255, 100, 100);
                return false;
            }
            return base.CanKillTile(i, j, type, ref blockDamaged);
        }
        private static bool IsInSnowBiome(int i, int j)
        {
            Player player = Main.LocalPlayer;
            return player.ZoneSnow;
        }
        private static bool IsOreTile(int type)
        {
            return TileID.Sets.Ore[type];
        }
        private static bool PlayerHasLavaPickaxe(Player player)
        {
            Item heldItem = player.HeldItem;
            return heldItem.type == ItemID.MoltenPickaxe;
        }

    }
}
